﻿using Microsoft.Practices.Unity;
using SampleServiceInterfacesAndImplementation;

namespace UnitySamples
{
    public class Container_Configured_Registration_of_Types
    {
        /*
         * As an example of using the overloads of the RegisterType and Resolve 
         * methods, the following code registers a mapping for an interface 
         * named ILogger and specifies that the container should return an 
         * instance of the TraceLogger class (which implements the 
         * ILogger interface).
         * 
         */
        public static void Sample()
        {
            IUnityContainer myContainer = new UnityContainer();
            //myContainer.RegisterType<ILogger, ConsoleLogger2>();
            myContainer.RegisterType<ILogger, ConsoleLogger>();
            ILogger myServiceInstance = myContainer.Resolve<ILogger>();
            //ILogger myServiceInstance = new ConsoleLogger();
            myServiceInstance.Write("hi ");
        }
    }
}